module SemanticText
  class DateExtractor
  	MONTHS = { 'January' => 1,
  			'February' => 2,
  			'March' => 3,
  			'April' =>4,
  			'May' =>5, 
  			'June' =>6,
  			'July' =>7,
  			'August' =>8,
  			'September' =>9,
  			'October' =>10,
  			'November' =>11,
  			'December' =>12
  		}

  	def extract_from(string)
  		fields = string.split ' '
  		day = fields[0]
  		month = MONTHS[fields[1]]
  		throw ExtractionFailed.new if month.nil?
  		year = fields[2]
		
  		Time.local(year, month, day)
  	end
  end
end